<?php
namespace App\Http\Controllers\ApiQd;

use App\Service\ApiQd\IncomeService as Income;
use Illuminate\Http\Request;

class IncomeController extends BaseController
{
    //收益

    public function __construct()
    {
        $this->db = new Income();
    }

    //列表
    public function getList(Request $request)
    {
        $token = $request->post('token', '');
        $uid = $this->db->addApiCount($token);
        if (!$uid) {
            return $this->toJson(-2, '没有登录');
        }
        $pages['start'] = $request->post('page', 1);
        $pages['limit'] = $request->post('size', 4);
        $res = $this->db->getList($pages, $uid);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }
}